/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.daoimpl;

import java.util.List;

import com.sesame.dao.UserDAO;
import com.sesame.domain.User;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * @author shubeta
 * 
 */
public class UserDAOImpl extends SqlMapClientDaoSupport implements UserDAO {

    public void addUser(User user) {
        getSqlMapClientTemplate().insert("addUser", user);
    }

    public void deleteUserById(Integer id) {
        getSqlMapClientTemplate().delete("deleteUserById", id);
    }

    @SuppressWarnings("unchecked")
    public List<User> getAllUser() {
        return (List<User>) getSqlMapClientTemplate()
                .queryForList("getAllUser");
    }

    public User getUserById(Integer id) {
        return (User) getSqlMapClientTemplate().queryForObject("getUserById",
                id);
    }

    public User getUserByEmail(String email) {
        return (User) getSqlMapClientTemplate().queryForObject(
                "getUserByEmail", email);
    }

    public User getUserByNickName(String nickName) {
        return (User) getSqlMapClientTemplate().queryForObject(
                "getUserByNickName", nickName);
    }

    public void updateUserLastLogin(User user) {
        getSqlMapClientTemplate().update("updateUserLastLogin", user);
    }

    public void updateUserPassword(User user) {
        getSqlMapClientTemplate().update("updateUserPassword", user);
    }

    public void updateUserDetail(User user) {
        getSqlMapClientTemplate().update("updateUserDetail", user);
    }

    public void updateHeadPic(User user) {
        getSqlMapClientTemplate().update("updateUserHeadPic", user);
    }
}